<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link rel="stylesheet" href="Console/styles/main-styles.css">
	<link href="Console/styles/js-console.css" rel="stylesheet" />
</head>
<body>
	<div id="wrapper">
        <h3>
            Write a function that counts how many times given number appears in given array. Write a test function to check if the function is working correctly.
        </h3>
		<br />
		<div id="console">
		</div>
	</div>
	<script src="Console/scripts/js-console.js">	  
	</script>		  
	<script>

	var myArray = [1,2,3,3,3,2,1,2,3,4,5,5,6,8];

	function timesInArray(array) {
	    var counter = 0;
	    var key = 5;

	    for (var i = 0; i < array.length; i++) {
	        if (array[i] === key) {
	            counter++;
	        }
	    }

	    return counter;
	}

	jsConsole.writeLine(timesInArray(myArray));

	function myTestFunc() {
	    var expected = 2;
	    var actual = timesInArray(myArray);

	    jsConsole.writeLine(actual == expected);
	}

	myTestFunc();

	</script>
</body>
</html>
